package com.cold.demo.web.util;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Administrator
 */
public class PageUtil {

    public static<T> List<T> getPage(List<T> all, int pageNum, int pageSize){
        if (all==null){
            return new ArrayList<>();
        }
        List<T> pageList = new ArrayList<>();
        int start = (pageNum - 1) * pageSize;
        int end = start + pageSize;
        if(start < all.size()){
            if(end >= all.size()){
                end = all.size();
            }
            for(int i = start ; i < end; i++){
                pageList.add(all.get(i));
            }
        }
        return pageList;
    }
}
